from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter

# 加载文本文件
loader = TextLoader('../../Data/JourneyToTheWest.txt')
documents = loader.load()

# 分割文本
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
texts = text_splitter.split_documents(documents)

print(len(texts))  # 打印分割后的文本块数量
